package com.huawei;

/**
 * Created by Z-hong on 2024/7/23.
 */
import java.util.*;



public class HJ71 {
    static public String MATCH="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String expression=sc.next();
        String str=sc.next();
        expression=expression.toLowerCase();
        str = str.toLowerCase();

        char[] exArr = expression.toCharArray();
        char[] stArr = str.toCharArray();
        if(exArr[exArr.length-1]!='*'&&exArr[exArr.length-1]!='?'&&exArr[exArr.length-1]!=stArr[stArr.length-1]) {

            System.out.println(false);
            return;
        }
        int i=0,j=0;
        System.out.println(isMatch(exArr,stArr,i,j));
    }


    public static Boolean isMatch(char[] exArr, char[] stArr, int i, int j) {
        if(i>=exArr.length&&j>=stArr.length) return true;
        if(i>=exArr.length||j>=stArr.length) return false;
        if(exArr[i]=='*') {
            int k=j;
            if(!MATCH.contains(String.valueOf(stArr[j]))){
                return isMatch(exArr,stArr,i+1,j+1);
            }
            if(i+1>=exArr.length) return true;
            while(k<stArr.length){
                if(stArr[k]==exArr[i+1]||exArr[i+1]=='*'||exArr[i+1]=='?'){
                    if(isMatch(exArr,stArr,i+1,k)){return true;};
                }
                k++;
            }
        }else if(exArr[i]=='?'&&MATCH.contains(String.valueOf(stArr[j]))){
            i++;j++;
            return isMatch(exArr,stArr,i,j);
        }else if(exArr[i]==stArr[j]){
            i++;j++;
            return isMatch(exArr,stArr,i,j);
        }
         return false;
    }
}
